<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core">
    <body>
        <p:dialog id ="dlg" modal="false"    visible="#{sessionScope._look_up_name eq 'MatchContextBackingBean'}">
            <div style="width: 600px">
                <table>
                    <tr>
                        <td>
                            <label>#{i18n['generator.match.common.name']}</label>
                        </td>
                        <td colspan="2">
                            <label>#{i18n['generator.match.common.prefix']}</label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <h:inputText value="#{matchBackingBean.newMatch.name}"/>
                        </td>
                        <td>
                            <h:inputText value="#{matchBackingBean.newMatch.prefix}"/>
                        </td>
                        <td>
                            <p:commandButton icon="ui-icon-plusthick" actionListener="#{matchBackingBean.onSave()}"/>
                        </td>
                    </tr>
                </table>

                <p:dataGrid
                        value="#{matchBackingBean.matchs}"
                        columns="1"
                        var="var" 
                        rows="10">
                    <p:column style="background-color: white;">
                        <table width="100%">
                                <tr>
                                    <td align="left">
                                            <h:panelGrid columns="2">
                                                <p:commandLink value="#{var.name} Prefix:[#{var.prefix}]" actionListener="#{matchBackingBean.openMatchContext(var)}" style="width: 100%"  update="@form"/>
                                                <h:commandLink value="" />
                                            </h:panelGrid>
                                    </td>
                                    <td align="right">
                                        <h:panelGrid columns ="3">
                                            <p:commandButton icon="ui-icon-check" actionListener="#{matchBackingBean.openMatchContext(var)}"/>
                                            <p:commandButton icon="ui-icon-clipboard" actionListener="#{matchBackingBean.openMatchContext(var)}"/>
                                            <p:commandButton icon="ui-icon-closethick" actionListener="#{matchBackingBean.onRemove(var)}"/>
                                        </h:panelGrid>
                                    </td>
                                </tr>
                            </table>
                        </p:column>
                </p:dataGrid>
                <br/>
                <p:panel header="Match">
                    <h:panelGrid columns="6">
                        <h:outputText value="#{i18n['generator.match.common.template']}"/>
                        <p:selectOneMenu style="width: 128px" >
                            <c:forEach items="#{matchContextBackingBean.templates}" var="template">
                                <f:selectItem itemLabel="#{template.name}"/>
                            </c:forEach>
                        </p:selectOneMenu>
                        <h:outputText value="#{i18n['generator.match.common.name']}"/>
                        <h:inputText value="#{matchBackingBean.match.name}"/>
                        <h:outputText value="#{i18n['generator.match.common.prefix']}"/>
                        <h:inputText value="#{matchBackingBean.match.prefix}"/>
                        <h:outputText value="#{i18n['generator.match.common.relocate']}"/>
                        <p:selectOneMenu style="width: 128px">
                            <f:selectItem itemLabel="#{i18n['common.itemlabel.yes']}" itemValue="#{i18n['common.itemvalue.yes']}"/>
                            <f:selectItem itemLabel="#{i18n['common.itemlabel.no']}" itemValue="#{i18n['common.itemvalue.no']}"/>
                        </p:selectOneMenu>
                        <h:outputText value="#{i18n['generator.match.common.relocatePath']}"/>
                        <h:inputText value="#{matchBackingBean.match.relocatePath}"/>
                        <h:outputText value="#{i18n['generator.match.common.replace']}"/>
                        <h:inputText value="#{matchBackingBean.match.replace}"/>
                        <h:outputText value="#{i18n['generator.match.common.active']}"/>
                        <p:selectOneMenu style="width: 128px">
                            <f:selectItem itemLabel="#{i18n['common.itemlabel.yes']}" itemValue="#{i18n['common.itemvalue.yes']}"/>
                            <f:selectItem itemLabel="#{i18n['common.itemlabel.no']}" itemValue="#{i18n['common.itemvalue.no']}"/>
                        </p:selectOneMenu>
                    </h:panelGrid>
                    <div style="text-align: right; width: 100%">
                        <p:commandButton value="#{i18n['common.save']}" actionListener="#{matchBackingBean.onModify}"/>
                    </div>
                    <br/>
                    <br/>
                    <p:panel header="Match Context">
                        <table>
                            <tr>
                                <td align="left">
                                        <h:outputText value="#{i18n['generator.matchContext.common.name']}"/>
                                </td>
                                <td colspan="2">
                                    <h:outputText value="#{i18n['generator.matchContext.common.value']}"/>
                                </td>
                            </tr>
                            <tr>
                                <td align="left">
                                    <h:inputText value ="#{matchContextBackingBean.newMatchContext.name}" id="matchContextName"/>
                                </td>
                                <td align="left">
                                    <h:inputText value ="#{matchContextBackingBean.newMatchContext.value}" id="matchContextValue"/>
                                </td>
                                <td align="left">
                                    <p:commandButton icon="ui-icon-plusthick" actionListener="#{matchContextBackingBean.onSave}" update="matchContext, matchContextName, matchContextValue"/>
                                </td>
                            </tr>
                        </table>
                        <p:dataGrid 
                            id="matchContext"
                            value="#{matchContextBackingBean.matchContexts}" 
                            var="var" 
                            rows="10" 
                            columns="1">
                            <h:column>
                                <table width="100%">
                                    <tr>
                                        <td align="left">
                                            <table>
                                                <tr>
                                                    <td><h:inputText value="#{var.name}" disabled="#{disabled}" style="#{nameStyle}"/></td>
                                                    <td> <h:inputText value ="#{var.value}" style="#{valueStyle}"/></td>
                                                </tr>
                                            </table>                                           
                                        </td>
                                        <td align="right">
                                            <table>
                                                <tr>
                                                    <td><p:commandButton icon ="ui-icon-check" actionListener="#{matchContextBackingBean.onStore(var)}" update="@form" /></td>
                                                    <td><p:commandButton icon ="ui-icon-closethick" actionListener="#{matchContextBackingBean.onRemove(var)}" update="@form" /></td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            </h:column>
                        </p:dataGrid>
                    </p:panel>
                </p:panel>
            </div>
        </p:dialog>
    </body>
</html>